﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.IO;

namespace Utils.WebFramework
{
    public class Httper : NameValues
    {
        internal Httper()
        {

        }

        internal Httper(string controller, string action)
        {
            this.controller = controller;
            this.action     = action;

            this.verb = string.Empty;
            int pos = action.LastIndexOf('$');
            if (pos != -1)
            {
                if (pos + 1 < action.Length)
                {
                    verb = action.Substring(pos + 1).Trim();
                }

                this.action = action.Substring(0, pos).Trim();
            }
        }

        internal Httper(string controller, string action, Httper referrer)
            : this(controller, action)
        {
            this.encoding = referrer.encoding;
        }

        /// <summary>
        /// a:add
        /// m:modify
        /// e:exec
        /// </summary>
        public string Verb 
        {
            get { return verb; }
        }

        public string Url 
        {
            get { return url; }
        }

        public string Browser 
        {
            get { return browser; }
        }

        public string Address 
        { 
            get { return address; } 
        }

        public Stream InStream 
        {
            get { return inStream; }
        }

        public Encoding Encoding 
        {
            get { return encoding; }
        }

        internal string controller = string.Empty;
        internal string action     = string.Empty;
        internal string verb       = string.Empty;
        internal string url        = string.Empty;
        internal string browser    = string.Empty;
        internal string address    = string.Empty;

        internal Stream  inStream  = null;
        internal Encoding encoding = Framework.GetFramework().Encoding;
    }
}
